//
//  LLTestViewController.swift
//  新印象
//
//  Created by wyl on 2016/12/28.
//  Copyright © 2016年 魏延龙. All rights reserved.
//

import UIKit

class LLTestViewController: UIViewController,UIPopoverPresentationControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    let model = sqlData()
    func prepareData() {
        model.age = Int(arc4random()%1000)
        model.tel = Int(arc4random()%2000)
//        model.name = "jack"
        model.email = "email"
    }
    
    @IBAction func creat(_ sender: Any) {
        LLSQLiteManager.shareManager.creatSQL(tableName: "users", model: model)
    }
    
    @IBAction func insert(_ sender: Any) {
//        prepareData()
//        LLSQLiteManager.shareManager.insertSQL(tableName: "users", model: model)
        let sender = sender as! UIButton
        print("点击了")
        let vc = popVC()
        vc.modalPresentationStyle = .popover
        vc.preferredContentSize = CGSize(width: 200, height: 30)
        vc.popoverPresentationController?.sourceRect = sender.bounds
        vc.popoverPresentationController?.sourceView = sender
        vc.popoverPresentationController?.permittedArrowDirections = .up
        vc.popoverPresentationController?.backgroundColor = .orange
        vc.popoverPresentationController?.delegate = self
        //弹出
        self.present(vc, animated: true) {
            
        }
    }
    func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
        return .none
    }
    
    @IBAction func query(_ sender: Any) {
        let datas = LLSQLiteManager.shareManager.queryAllSQL(tableName: "users", model: model)
        print(datas)

    }
//
//    @IBAction func update(_ sender: Any) {
//        LLSQLiteManager.shareManager.updateSQL(tableName: "users")
//    }
    

}

